export default {
  install(Vue, options) {
    Vue.prototype.readerd8 = options => {
      return new Promise((resolve, reject) => {
        try {
          if (global.readerd8) {
            resolve(global.readerd8)
          } else {
            /* eslint-disable */
            const obj = new ActiveXObject('ComRD800.RD800')
            global.readerd8 = obj
            resolve(global.readerd8)
          }
        } catch (e) {
          if ('ActiveXObject' in window) {
            alert('读写器控件没有安装,请安装控件后再试')
            window.location.href =
              'http://keisdom.oss-cn-hangzhou.aliyuncs.com/downloads/readerd8/dll.zip'
          } else {
            alert('您的浏览器不支持OCX控件。请安装控件或更换ie浏览器后再使用。')
          }
          reject(e)
        }
      })
    }
  }
}
